﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:behaviors="clr-namespace:Rio.Manager.Application.Behaviors"
             xmlns:mvvmLightCommand="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:Rio_Framework_Pages_Controls="clr-namespace:Rio.Framework.Pages.Controls;assembly=Rio.Framework.Pages"
             x:Class="Rio.Manager.Application.Views.ManageWorkflowModelTabView"
             mc:Ignorable="d"
             d:DesignHeight="768"
             d:DesignWidth="1024">

    <UserControl.DataContext>
        <Binding Path="ManageWorkflowModelTab"
                 Source="{StaticResource Locator}" />
    </UserControl.DataContext>

    <Grid x:Name="LayoutRoot">

        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                <mvvmLightCommand:EventToCommand Command="{Binding InitializationCommand}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock Name="WorkflowModelsTextblock"
                   TextWrapping="Wrap"
                   Text="{Binding WorkflowModelsTextblock, Mode=OneWay}"
                   FontWeight="Bold"
                   Margin="10,10,0,10" />
        <Grid Margin="20,0,20,20"
              Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <telerik:RadToolBar>
                <telerik:RadMenuItem Command="{Binding CreateNewWorkflowCommand}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/newworkflow.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock Name="NewWorkflowTexBlock"
                                       TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding NewWorkflowTexBlock, Mode=OneWay}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

                <telerik:RadMenuItem Command="{Binding DeleteWorkflowCommand}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/deleteworkflow.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock Name="DeleteWorkflowTextblock" TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding DeleteWorkflowTextblock, Mode=OneWay}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

                <telerik:RadMenuItem Command="{Binding RefreshCommand}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/refresh.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock Name="RefreshTextblock" TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding RefreshTextblock, Mode=OneWay}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>
            </telerik:RadToolBar>
            <telerik:RadGridView Name="WorkflowDefinitionsGridView"
                                 ShowGroupPanel="False"
                                 IsFilteringAllowed="False"
                                 Grid.Row="1"
                                 AutoGenerateColumns="False"
                                 ItemsSource="{Binding WorkflowModels, Mode=TwoWay}"
                                 SelectedItem="{Binding SelectedWorkflow, Mode=TwoWay}">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn UniqueName="WorkflowDefinitionsGridView_Name"
                                                DataMemberBinding="{Binding Name, Mode=TwoWay, StringFormat='dd/MM/yyyy'}"
                                                Header="{Binding ManageWorkflowModelTab.WorkflowDefinitionsGridView_Name, Source={StaticResource Locator}, Mode=TwoWay}"
                                                IsReadOnly="True" />
                    <telerik:GridViewDataColumn UniqueName="WorkflowDefinitionsGridView_Description"
                                                DataMemberBinding="{Binding Description, Mode=TwoWay, StringFormat='dd/MM/yyyy'}"
                                                Header="{Binding ManageWorkflowModelTab.WorkflowDefinitionsGridView_Description, Source={StaticResource Locator}, Mode=TwoWay}"
                                                IsReadOnly="True" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </Grid>
        <telerik:RadBusyIndicator BusyContent=""
                                  IsBusy="{Binding BusyIndicator.IsBusy, Mode=OneWay}"
                                  Grid.RowSpan="3"
                                  d:IsHidden="True" />
    </Grid>
</UserControl>
